/*
 * Copyright (c) 2023, 2024,yzc.cn All rights reserved.
 *
 */
package cn.yzc.read;

import cn.yzc.pojo.Student;
import cn.yzc.utils.TestFileUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import lombok.extern.slf4j.Slf4j;

import java.io.File;

/**
 * <p>Project: EasyExcel - SimpleRead</p>
 * <p>Powered by yzc On 2024-03-20 16:43:41</p>
 * <p>描述：<p>
 *
 * @author yzc [youzhicheng0415@163.com]
 * @version 1.0
 * @since 17
 */
@Slf4j
public class SimpleRead {
    public static void main(String[] args) {
        String fileName = TestFileUtil.getPath() + "simpleWrite1710923908348.xlsx";
        // 这里默认每次会读取100条数据 然后返回过来 直接调用使用数据就行
        // 具体需要返回多少行可以在`PageReadListener`的构造函数设置
        EasyExcel.read(fileName, Student.class, new PageReadListener<Student>(dataList -> {
            for (Student demoData : dataList) {
                log.info("读取到一条数据{}", demoData.toString());
            }
        })).sheet().doRead();
    }
}
